<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>$default_template_handler_func</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="api.variables.html" title="Chapter 13. Smarty Class Variables">
<link rel="prev" href="variable.default.config.handler.func.html" title="$default_config_handler_func">
<link rel="next" href="variable.direct.access.security.html" title="$direct_access_security">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">$default_template_handler_func</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="variable.default.config.handler.func.html">Prev</a> </td>
<th width="60%" align="center">Chapter 13. Smarty Class Variables</th>
<td width="20%" align="right"> <a accesskey="n" href="variable.direct.access.security.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="$default_template_handler_func">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="variable.default.template.handler.func"></a>$default_template_handler_func</h2></div></div></div>
<p>
  This function is called when a template cannot be obtained from
  its resource.
 </p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>
   The default handler is currently only invoked for file resources. 
   It is not triggered when the resource itself cannot be found, in which case a SmartyException is thrown.
  </p>
</div>
<div class="example">
<a name="id419421"></a><p class="title"><b>Example 13.5. $default_template_handler_func</b></p>
<div class="example-contents"><pre class="programlisting">

&lt;?php

$smarty = new Smarty();
$smarty-&gt;default_template_handler_func = 'my_default_template_handler_func';

/**
 * Default Template Handler
 *
 * called when Smarty's file: resource is unable to load a requested file
 * 
 * @param string   $type     resource type (e.g. "file", "string", "eval", "resource")
 * @param string   $name     resource name (e.g. "foo/bar.tpl")
 * @param string  &amp;$content  template's content
 * @param integer &amp;$modified template's modification time
 * @param Smarty   $smarty   Smarty instance
 * @return string|boolean   path to file or boolean true if $content and $modified 
 *                          have been filled, boolean false if no default template 
 *                          could be loaded
 */
function my_default_template_handler_func($type, $name, &amp;$content, &amp;$modified, Smarty $smarty) {
    if (false) {
        // return corrected filepath
        return "/tmp/some/foobar.tpl";
    } elseif (false) {
        // return a template directly
        $content = "the template source";
        $modified = time();
        return true;
    } else {
        // tell smarty that we failed
        return false;
    }
}

?&gt;

  </pre></div>
</div>
<br class="example-break">
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="variable.default.config.handler.func.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="api.variables.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="variable.direct.access.security.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">$default_config_handler_func </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> $direct_access_security</td>
</tr>
</table>
</div>
</body>
</html>
